/*
 * MODULE  NAME  :
 * PROGRAM NAME  : type.h
 * AUTHOR        : HOTMOCHA
 * CREATE  DATE  : 2015-01-16 22:29:42
 * PROGRAM DESC  :
 *
 * HISTORY       :
 *
 */
#ifndef _H_TYPE_H_
#define _H_TYPE_H_
#include "simplebuf.h"
#include "ilog.h"

#define BOOL	int
#define TRUE	1
#define FALSE  0

/*+++++++++++++++++++++++mapentry定义+++++++++++++++++++++*/
#define TYPEINVALID		-20001

#define KEYMAXLEN		256
#define LONGTYPE		1
#define DOUBLETYPE		2
#define STRING			3		//必须以0结尾的普通字符串	
#define	CUSTOM			4		//自定义结构

typedef struct {
	char key[KEYMAXLEN + 1];
	int type;
	union {
		long value_l;
		double value_d;
		Buf *value_str;
		void *value_p;
	};
} MapEntry;

void FreeMapEntry(MapEntry *entry);
MapEntry* InitMapEntry();
int PrintfMapEntry(MapEntry *m);
int SetLongValue(MapEntry *map, char *key, long value);
int GetLongValue(MapEntry *map, long *value);
int SetDoubleValue(MapEntry *map, char *key, double value);
int GetDoubleValue(MapEntry *map, double *value);
int SetStringValue(MapEntry *map, char *key, char* value);
int GetStringValue(MapEntry *map, char* value, int len);
int SetCustomValue(MapEntry *map, char *key, void *value, int typelen );
int GetCustomValue(MapEntry *map, void *value, int typelen );
int MapEntryCmp(MapEntry *a, MapEntry *b);
/*-----------------------mapentry定义结束---------------------*/
		
#endif
